package sam.learn.framework.dynamicDataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;

@Configuration
public class LoadDbDynamicDataSourceConfig implements ApplicationListener<ContextRefreshedEvent> {


    //核心动态数据源组件
    @Autowired
    private DbDynamicDataSourceLoader dbDynamicDataSourceLoader;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        //获取主数据源对象
        dbDynamicDataSourceLoader.loadAllDatasource();
    }
}
